/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-08-20
 * Time: 22:20
 */
public class demo1 {
    public static int addDigits(int num) {
        if(num<10) {
            return num;
        }
        int sum=0;
        while(num>=10) {
            sum=0;
            while(num>=10) {
                sum+=num%10;
                num/=10;
            }
            sum+=num;
            num=sum;
        }
        return num;
    }

    public static void main(String[] args) {
        addDigits(38);
    }
}
